package com.fowo.api.sys.entity;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fowo.api.common.mybatis.handlers.IdListTypeHandler;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.hibernate.validator.constraints.Length;

import javax.validation.constraints.NotNull;
import java.util.List;

@EqualsAndHashCode(callSuper = true)
@Schema(title = "部门")
@Data
@TableName(value = "sys_department", autoResultMap = true)
public class SysDepartment extends SysBase {

    @Schema(title = "上级部门编号")
    @NotNull(message = "上级部门不能为空")
    private Long parentId;

    @Schema(title = "上级部门编号数组")
    @TableField(typeHandler = IdListTypeHandler.class)
    private List<Long> parents;

    @Schema(title = "部门名称")
    @NotNull(message = "部门名称不能为空")
    @Length(max = 50, message = "部门名称最长 50 个字符")
    private String name;

    @Schema(title = "部门代码")
    @NotNull(message = "部门代码不能为空")
    @Length(max = 50, message = "部门代码最长 50 个字符")
    private String code;

    @Schema(title = "顺序")
    private Integer priority;
}
